var config = require('../../config');
var whost = config.whost;
var request = require('../../support').request2;

/**
 * 获取群组公告详情
 * @return {promise}
 */
exports.getNotice = function (context, noticeId) {
  return request(context, {
    url: whost + '/hk-api/api/json/group/getGroupNoticeDetail',
    data: {
      billboardId: noticeId
    }
  }).then(function (data) {
    return {
      notice: data.entity
    };
  });
};

/**
 * 获取用户在群组中的身份
 * @return {promise}
 */
exports.roleOfGroup = function (context, userId, roomId) {
  // roleType[群角色类型][1:普通用户,2:管理员,3:群主][Integer]
  return request(context, {
    url: whost + '/hk-api/api/json/group/getGcUserRole',
    data: {
      userId: userId,
      gcRoomId: roomId,
    }
  });
};

/**
 * 删除公告
 * @return {promise}
 */
exports.delNotice = function (context, userId, userName, noticeId) {
  return request(context, {
    url: whost + '/hk-api/api/json/group/delGroupNoticeById',
    data: {
      userId: userId,
      optAt: userName,
      billboardId: noticeId
    }
  });
};